<span page-title ng-model="host">{{ 'Traces for: ' | translate }} {{ host.name }}</span>

<div ng-hide="host.hasContent()">
  <div data-extend-template="common/views/registration.html"></div>
</div>

<div ng-if="host && host.hasContent()" ng-hide="denied('edit_hosts', host)">
  <div data-block="messages" ng-show="table.rows.length > 0">
    <p bst-alert="info" >
      <span translate ng-show="remoteExecutionPresent">
        Only the Applications with a Helper can be restarted.
      </span>
      <span translate ng-show="!remoteExecutionPresent">
        Remote execution plugin is required to be able to run any helpers.
      </span>
    </p>
  </div>

  <form id="traceActionForm" method="post" action="/katello/remote_execution">
    <input type="hidden" name="remote_action" value="service_restart"/>
    <input type="hidden" name="name" ng-value="traceActionFormValues.helper"/>
    <input type="hidden" name="host_ids" ng-value="traceActionFormValues.hostIds"/>
    <input type="hidden" name="customize" ng-value="traceActionFormValues.customize"/>
    <input type="hidden" name="authenticity_token" ng-value="traceActionFormValues.authenticityToken"/>
  </form>

  <div bst-feature-flag="remote_actions">
    <h3 translate>Traces</h3>
    <h4 translate>Tracer helps administrators identify applications that need to be restarted after a system is patched.</h4>
    <button
      class="btn btn-default"
      type="button"
      ng-hide="denied('edit_hosts', host) || host.content_facet_attributes.katello_tracer_installed"
      ng-click="installTracerPackage(host)">
      <span translate>Enable Traces</span>
    </button>
  </div>

  <div data-extend-template="layouts/partials/table.html">
    <span data-block="list-actions" ng-hide="contentHost.readonly">
      <div bst-modal="performViaRemoteExecution(false)" model="host">
        <div data-block="modal-header" translate>Restart Services on Content Host "{{host.name}}"?</div>
        <div data-block="modal-body">
          <span translate>Are you sure you want to restart services on content host "{{ host.name }}"?</span>
          <span ng-show="host.rebootRequired()">
            <strong translate>Resolving the selected Traces will reboot this host.</strong>
          </span>
        </div>
        <span data-block="modal-confirm-button">
          <button class="btn btn-primary" ng-click="ok()">
            <span translate>Restart</span>
          </button>
        </span>
      </div>

      <span bst-feature-flag="remote_actions">
        <span class="btn-group" uib-dropdown>
          <button class="btn btn-default" type="button"
                  translate
                  ng-hide="denied('edit_hosts', host)"
                  ng-disabled="table.getSelected().length == 0 || !remoteExecutionPresent"
                  ng-click="openModal()">
            Restart Selected
          </button>
        </span>
      </span>
    </span>

    <span data-block="no-rows-message" translate>
      There are no Traces to display.
    </span>

    <span data-block="no-search-results-message" translate>
      Your search returned zero Traces.
    </span>

    <div data-block="table">
      <table bst-table="table" class="table table-striped table-bordered" ng-class="{'table-mask': table.working}">
        <thead>
          <tr bst-table-head row-select>
            <th bst-table-column="application" translate>Application</th>
            <th bst-table-column="app_type" translate>Type</th>
            <th bst-table-column="helper" translate>Helper</th>
          </tr>
        </thead>
        <tbody>
          <tr bst-table-row ng-repeat="trace in table.rows | filter:table.tracesCompare" row-select="trace">
            <td bst-table-cell >{{ trace.application }}</td>
            <td bst-table-cell >{{ trace.app_type }}</td>
            <td bst-table-cell >{{ trace.helper }}</td>
          </tr>
        </tbody>
      </table>
    </div>

  </div>
</div>
